import request from '@/utils/request';

/**
 * 用户列表
 */
export async function userList(data) {
  const res = await request.post('/user/userList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 用户在状态
export async function updateStatus(data) {
  const res = await request.post('/updateStatus', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 用户详情
export async function userInfo(data) {
  const res = await request.post('/user/userInfo', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 实名认证审核
export async function authentication(data) {
  const res = await request.post('/user/authentication', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 关注列表
export async function followUser(data) {
  const res = await request.post('/user/followUser', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//
// 用户明细
export async function amountLog(data) {
  const res = await request.post('/user/amountLog', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 修改用户余额
export async function setAmount(data) {
  const res = await request.post('/user/setAmount', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
}
export async function checkUser(data) {
  const res = await request.post('/user/checkUser', data);
  if (res.data.code === 0) {
    return res.data.data;
  } else {
    return res.data.data;
  }
}
// 用户申请获取联系审核接口
export async function agreeCheck(data) {
  const res = await request.post('/user/agreeCheck', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
}

// 获取小程序

export async function getUserinvitexcxurl(data) {
  const res = await request.post('/user/getUserinvitexcxurl', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
}
export async function editUserDisable(data) {
  const res = await request.post('/user/editUserDisable', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
}

export async function distributorEditState(data) {
  const res = await request.post('/associate/editState', data);
  if (res.data.code === 0) {
    return res.data;
  } else {
    return res.data;
  }
}
export async function distributorList(params) {
  const res = await request.get('/associate', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
